from celery import Celery
import django
import os

# 创建celery主程序对象
app = Celery("luffy")

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'luffyapi.settings.dev')

django.setup()

# 加载配置
app.config_from_object("mycelery.config")

# 注册任务
app.autodiscover_tasks(["mycelery.sms", "mycelery.mail", "mycelery.order"])

# 通过终端来启动celery
# celery -A mycelery.main worker --loglevel=info  # 在ubuntu上运行
# celery -A mycelery.main worker --loglevel=debug
# celery -A mycelery.main worker --loglevel=info -P gevent  # 在windows上运行


# 运行celery的定时任务程序，以下命令
# celery -A mycelery.main beat
# celery -A mycelery.main worker --loglevel=info -P gevent  # 在windows上运行
